#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
from flask import Blueprint
import dbOperate

db1 = dbOperate.dbOperate('10.37.133.21', 'spider', 'spider', 'spider')
issue = Blueprint('issue', __name__)


@issue.route('/get_issue', methods=['GET'])
def get_issue():
    # sql1 = 'select daytotal,dayresolve from issuenum where date = DATE_FORMAT(NOW(),"%Y-%m-%d");'
    sql = 'select daytotal,dayresolve,montotal,monresolve,lowgrademonth,highgradepermon,commentpermon,resolvepermon from issuenum'
    see = db1.exe_query(sql)
    hostname = see[0][0]
    value = see[0][1]
    value2 = see[0][2]
    value3 = see[0][3]
    value4 = see[0][4]
    value5 = see[0][5]
    value6 = see[0][6]
    value7 = see[0][7]
    jsonData = {}
    jsonData['hostname'] = hostname
    jsonData['value'] = value
    jsonData['value2'] = value2
    jsonData['value3'] = value3
    jsonData['value4'] = value4
    jsonData['value5'] = value5
    jsonData['value6'] = value6
    jsonData['value7'] = value7
    j = json.dumps(jsonData, ensure_ascii=False)
    print('isusse--------' + str(len(j)))
    return j
